<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
        .ball {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background-color: red;
        }
    </style>
</head>

<body>
    <div id='app'>
        <button @click='flag=!flag'>切换动画</button>
        <transition @before-enter="beforeEnter" @enter="enter" @after-enter="afterEnter" :duration="{enter:1000,leave:1000}">
            <div v-show="flag" class="ball"></div>
        </transition>
    </div>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                flag:false
            },
            methods: {
                beforeEnter(el) {
                    el.style.transform = 'translate(0,0)'
                },
                enter(el, done) {
                    el.offsetWidth;
                    el.style.transition = "all 1s ease"
                    el.style.transform = "translate(200px,500px)"
                    done()
                },
                afterEnter(el) {
                    console.log("进场之后");
                    this.flag = false
                }
            }
        })
    </script>
</body>

</html>